<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>购物车</title>
		<link rel="stylesheet" type="text/css" href="{{__PUBLIC__}}/Home/css/cart.css"/>
		<link rel="stylesheet" type="text/css" href="{{__PUBLIC__}}/Home/css/footer.css"/>
		<link rel="shortcut icon" href="{{__PUBLIC__}}/Home/images/favicon.ico">
		<script type="text/javascript" src="{{__PUBLIC__}}/Home/js/jquery-1.8.2.min.js"></script>
			<style type="text/css">
				*{
					margin: 0;
					padding: 0;
				}
				#progress-cart-dy{
                	display: block;
	            }
	            #progress-confirm-dy{
	                display: none;
	            }
				 #progress-submit-dy{
	                display: none;
	            }
			</style>
		<script>
			$(function(){
					//选择数量
				$('.g-add-dy').live('click',function(){
					var num = parseInt($(this).siblings('.p-total-num').val());
					num++;
					$(this).siblings('.p-total-num').val(num);
					var kkey = $(this).parents('.table-2-dy').find('.kkey').val();
					$.ajax({
						//请求地址
					url:"{{U('addReduce')}}",
						//发送数据
					data:{num:num,kkey:kkey},
						//请求类型
					type:'post',
						//返回的数据类型
					dataType:'json',
						//成功返回
					success:function(phpData){
						location.reload();
					}
				})
				})
				$('.g-reduce-dy').live('click',function(){
					var num = $(this).siblings('.p-total-num').val();
					num = parseInt(num)-1;
					if(num <= 0){
						num = 1;
					}
					$(this).siblings('.p-total-num').val(num);
					var kkey = $(this).parents('.table-2-dy').find('.kkey').val();
						$.ajax({
							//请求地址
						url:"{{U('addReduce')}}",
							//发送数据
						data:{num:num,kkey:kkey},
							//请求类型
						type:'post',
							//返回的数据类型
						dataType:'json',
							//成功返回
						success:function(phpData){
							location.reload();
						}
					})
				})
					//全选
				$('#checkAll').click(function(){
					//找到所有的复选框，添加checked=checked属性
					$('.good-list-dy :checkbox').attr('checked','checked');
				})
					//全不选
				$('#checkNo').click(function(){
						//找到所有的checkbox，取消他们的checked属性
					$('.good-list-dy :checkbox').removeAttr('checked');
				})
				$('.sub-total-dy').click(function(){
						//是否登陆验证
					if("$_SESSION['username']"){
						location.href="{{U('OrderList/check')}}";
					}else{
						alert("请登陆！");
					}
				});
			})
		</script>
	</head>
	<body>
		<!--顶部-->
		{{include file="VIEW_PATH/Common/orderHead.php"}}
			<!--top----------------------------------head-->
		<div class="layout-dy">
			<div class="list-dy">
				<div class="good-list-dy">
					<div>
						<table border="0" cellspacing="" cellpadding="" class="table-bt-dy">
							<tr class="title-dy">
								<th width="37" height="30" style="padding-right: 3px;"><input type="checkbox" name="" id="checkNo" value="" /></th>
								<th width="617" height="30">商品</th>
								<th width="155" height="30">单价（元）</th>
								<th width="140" height="30">数量</th>
								<th width="140" height="30">小计（元）</th>
								<th width="100" height="30">操作</th>
							</tr>
						</table>
					</div>
					<div class="goods-lists-dy">
						{{if value="!$data['goods']"}}
							<div class="kong">
								亲，您购物车里还没有物品哦，快去逛逛吧！ 
							</div>
						{{else}}
						<!-- <form action="" method="post"> -->
							{{foreach from="$_SESSION['cart']['goods']" key="$k" value="$v"}}
							<table border="0" cellspacing="" cellpadding="" class="table-2-dy">
								<input type="hidden" value="{{$k}}" class="kkey">
								<tr height="105">
									<td width="37" height="30">
										<input type="checkbox" name="choose" checked="checked" id="choose" value="1" />
									</td>
									<td width="617" height="30">
										<div class="good-area-dy">
											<p class="g-img-dy"><a href=""><img src="{{__ROOT__}}/{{$v['img']}}" alt="" /></a></p>
											<p class="g-name-dy"><a href="">{{$v['name']}}</a></p>
											<p class="g-color-dy">颜色：{{$v['options']['颜色']}}</p>
											<p class="g-explain-dy"></p>
										</div>
									</td>
									<td width="155" height="30"><span>¥{{$v['price']}}</span></td>
									<td width="140" height="30" class="g-num-dy">
										<input type="text" name="" class="p-total-num" value="{{$v['num']}}" />
										<a href="javascript:;" class="g-add-dy"></a>
										<a href="javascript:;" class="g-reduce-dy"></a>
									</td>
									<td width="140" height="30" class="g-stotal-dy"><span>¥<span class="total">{{$v['total']}}</span></span></td>
									<td width="100" height="30" class="g-del-dy"><span><a href="javascript:;" onclick="if(confirm('确定删除吗？')) location.href='{{U('OrderList/del',array('k'=>$k))}}'">X</a></span></td>
								</tr>
							</table>
						{{endforeach}}
					</div>
				</div>
				<div class="hr-20"></div>
				<div class="total-dy">
					<div class="total-left-dy">
						<input type="checkbox" name="" id="checkAll" checked="checked" value="" />&nbsp;&nbsp;&nbsp;&nbsp;<span>全选</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="">删除选中商品</a>
					</div>
					<div class="total-right-dy">
						<table border="0" cellspacing="" cellpadding="" class="total-table-dy">
							<tr>
								<th>总计金额：</th><td>¥{{$data['total']}}</td>
							</tr>
							<tr>
								<th>共节省：</th><td>¥0.00</td>
							</tr>
							<tr class="no-free">
								<th>合计(不含运费)：</th><td><span>¥{{$data['total']}}</span></td>
							</tr>
						</table>
					</div>
				</div>
				<div class="hr-20"></div>
				<div class="action-area-dy">
						<input type="button" value="去结算" class="sub-total-dy"/>
						<a href="{{U('Index/index')}}">继续购物</a>
					<!-- </form> -->
					{{endif}}
				</div>
				
			</div>
		</div>
		
		<div class="hr-60"></div>
		<!------------------------------底部-------------------------->
		{{include file="VIEW_PATH/Common/footer.php"}}
		
	</body>
</html>
	</body>
</html>
